package app.netant.book.book14;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
import app.netant.book.base.BaseEntity;
import app.netant.book.base.BasePage;
import cn.lily.com.enviroment.Enviroment;

public class Book14Page extends BasePage {

	public Book14Page(String netSite) {
		super(netSite);
		this.tableKey = "book14";
		this.selectKey = "body .sort .left .list .listable .dysx1 strong a";
		this.preHref = "https://www.14shucheng.com";
	}

	@Override
	public String buildHref(Element element) {	
		String href = element.attr("href");
		if(href.startsWith("/")){
			href = this.preHref + href;
		}
		return href;
	}

	@Override
	public BaseEntity buildEntity() {
		return new Book14Entity();
	}

	@Override
	public BaseDetail buildDetail(String href) {
		return new Book14Detail(href);
	}

	@Override
	public void afterEntity(BaseEntity entity, Element element) {
		Elements memo = element.parents().parents().parents().select(".dysx font[color='#777777']");
		if(memo.size()>0){
			entity.setNovelMemo(this.getString(memo.text()));
		}
	}
	
	public static void main(String[] args) {
		Enviroment.createEnv();
		Enviroment.getEnv().getLogBean().beginLog();
		Book14Page page = new Book14Page("http://www.14book.net/ds/1.html");
		page.analyseHref();
	}
	
}
